package com.atguigu.juc.chap02;

import java.util.concurrent.locks.ReentrantLock;

/**
 * @author Taeyang
 * @date 2025/3/31
 */
public class ReentrantLockDemo01 {

    private static final ReentrantLock lock = new ReentrantLock();

    public static void a() {
        lock.lock();
        try {
            System.out.println("a begin");
            b();
            System.out.println("a end");
        } finally {

            lock.unlock();
        }
    }

    public static void b() {
        lock.lock();
        try {
            System.out.println("b begin");
            System.out.println("b end");
        } finally {
            lock.unlock();
        }
    }

    public static void main(String[] args) {
        a();
    }
}
